package test.lym.com.mytest.Service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

import androidx.annotation.Nullable;

import java.util.ArrayList;
import java.util.List;

import test.lym.com.mytest.entity.Coordinate;
import test.lym.com.mytest.utils.CustomViewManager;

/**
 * @content：
 * @author： liyanmei
 * @time： 2017/9/11$
 * @email： lym_liyanmei@qq.com
 */
public class FloatService extends Service {
    @Override
    public void onCreate() {
        super.onCreate();

    }

    public static final String ACTION_BIND = "test.lym.com.mytest.Service.FloatService";

    @Override
    public void onStart(Intent intent, int startId) {
        super.onStart(intent, startId);

    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        String action = intent.getAction();
        if (ACTION_BIND.equals(action)) {

            // TODO: 2017/9/11 测试数据
            List<Coordinate> list = new ArrayList<>();
//            list.add(new Coordinate("ceshi", 100, 300));
//            list.add(new Coordinate("数据", 0, 0));
//            list.add(new Coordinate("测试数据", 400, 500));
            CustomViewManager.getInstance(this).setData(list).showFloatViewOnWindow();
        }
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        CustomViewManager.getInstance(this).hideFloatViewOnWindow();
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

}
